package cn.schoolwow.ams.module.config.bean;

import cn.schoolwow.ams.domain.response.AMSResult;
import cn.schoolwow.ams.module.config.domain.QuickAMSException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class AMSExceptionHandler {

    @ExceptionHandler(QuickAMSException.class)
    @ResponseBody
    public AMSResult handleException(QuickAMSException ex) {
        ex.targetException.printStackTrace();
        return new AMSResult(ex.targetException.getMessage());
    }

}
